#include"YUVStream.h"

YUVStream::YUVStream()
{
    size  = 0;
}

YUVStream::~YUVStream()
{

}

void YUVStream::Push(YuvBuffer* yuvbuffer)
{
    queueMutex.lock();
    yuvbuffers.push(yuvbuffer);
    size++;
    queueMutex.unlock();
}

YuvBuffer *YUVStream::Front()
{
    queueMutex.lock();
    YuvBuffer * ret = yuvbuffers.front();
    queueMutex.unlock();
    return ret;
}

void YUVStream::Pop()
{
    queueMutex.lock();
    yuvbuffers.pop();
    size--;
    queueMutex.unlock();
}

void YUVStream::Clear()
{
    while(!yuvbuffers.empty()){
        YuvBuffer * tem = yuvbuffers.front();
        yuvbuffers.pop();
        delete  tem;
    }
}

int YUVStream::Size()
{
    int ret;
    queueMutex.lock();
    ret = size;
    queueMutex.unlock();
    return ret;
}
